package com.gt.admin.controller;

import com.gt.common.annotation.Log;
import com.gt.common.core.controller.BaseController;
import com.gt.common.core.domain.AjaxResult;
import com.gt.common.core.page.TableDataInfo;
import com.gt.common.enums.BusinessType;
import com.gt.admin.domain.vo.QuestionnaireManageVO;
import com.gt.admin.service.IQuestionnaireManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "sc-问卷管理")
@RestController
@RequestMapping("/questionnaire-manage")
public class QuestionnaireManageController extends BaseController {
    @Autowired
    private IQuestionnaireManageService questionnaireManageService;

    /**
     * 查询筛查问卷
     */
    @ApiOperation(value = "查询筛查问卷")
    @GetMapping("/list")
    public TableDataInfo list(QuestionnaireManageVO questionnaireManageVO){
        startPage();
        return getDataTable(questionnaireManageService.getList(questionnaireManageVO));
    }

    /**
     * 根据id查询筛查问卷
     */
    @ApiOperation(value = "根据id查询筛查问卷")
    @GetMapping("/{id}")
    public AjaxResult select(@PathVariable("id")Long id){
        return AjaxResult.success(questionnaireManageService.getById(id));
    }

    /**
     * 审核
     */
    @ApiOperation(value = "审核")
    @Log(title = "筛查问卷管理", businessType = BusinessType.UPDATE)
    @PutMapping("/{id}/{status}")
    public AjaxResult audit(@PathVariable("id")Long id, @PathVariable("status")String status){
        return toAjax(questionnaireManageService.audit(id,status));
    }
}
